import axios from 'axios'
import config from '../config'

export function getTaskList(date, page = 1) {
  let query = 'beginTime=gt=' + date
  return ps(query, page)
}

export function getHistory(date, page) {
  let query = 'beginTime=lt=' + date
  return ps(query, page)
}

export function ps(query, page) {
  return axios.get(config.SERVER_URL + window.apiPath + `/schedule-tasks-ps?query=${query}&page=${page}&size=${config.PAGE_SIZE}`, {responseType: 'json'})
    .then(resp => {
      return {
        dataCount: parseInt(resp.headers['x-total-count'], 10),
        data: resp.data
      }
    })
}
